package com.douguo.recipe.sina;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 轻量持久化
 * 
 */
public class SharePersistent {

	public static final String DEFAULT_PREFS_NAME = "douguo";

	private static SharePersistent instance;

	private SharePersistent() {

	}

	public static SharePersistent getInstance() {
		if (instance == null) {
			instance = new SharePersistent();
		}
		return instance;
	}

	public void savePerference(Context context, String key, String value) {
		SharedPreferences settings = context.getSharedPreferences(
				DEFAULT_PREFS_NAME, 0);
		SharedPreferences.Editor editor = settings.edit();
		editor.putString(key, value);
		editor.commit();
	}

	public String getPerference(Context context, String key) {
		SharedPreferences settings = context.getSharedPreferences(
				DEFAULT_PREFS_NAME, 0);
		return settings.getString(key, "");
	}
}
